<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

</head>
<body>
<input id="num" type="text">
<button id="btn">点击计算阶乘</button>
<div id="root"></div>

<script>
    const btn = document.getElementById("btn");

    function JC(n) {
        if (n <= 1) return 1;
        else return n * JC(n - 1);
    }

    btn.onclick = function () {
        const num = document.getElementById('num').value
        const root = document.getElementById('root')
        root.innerHTML = JC(num)
    }
</script>

</body>
</html>